"""
Case Type   : 资源池化
Case Name   : 扩容工具查看参数信息、版本信息
Create At   : 2024.10
Owner       : chen
Description :
    1.执行查看参数信息命令
    gs_expansion --help
    gs_expansion -?
    2.执行查看版本信息
    gs_expansion -V
    gs_expansion --version
Expect      :
    1、显示正常
    2、显示正常
"""

import os
import unittest
from testcase.utils.Logger import Logger
from yat.test import Node
from yat.test import macro

class SharedStorage(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f'-----{os.path.basename(__file__)} start-----')
        self.pri_node = Node('PrimaryDbUser')
        

    def test_shared_storage(self):
        text = '-----step1: gs_expansion --help' \
            ' expect: 显示正常-----'
        self.log.info(text)
        cmd = f'''source {macro.DB_ENV_PATH}; gs_expansion --help'''
        self.log.info(cmd)
        res = self.pri_node.sh(cmd).result()
        self.log.info(res)
        self.assertIn('gs_expansion -U USER -G GROUP -X XMLFILE -h nodeList [-L]',
        res, text + '失败')

        text = '-----gs_expansion -? expect: 显示正常-----'
        self.log.info(text)
        cmd = f'''source {macro.DB_ENV_PATH}; gs_expansion -?'''
        self.log.info(cmd)
        res = self.pri_node.sh(cmd).result()
        self.log.info(res)
        self.assertIn('gs_expansion -U USER -G GROUP -X XMLFILE -h nodeList [-L]',
        res, text + '失败')

        text = '-----step2: gs_expansion -V expect: 显示正常-----'
        self.log.info(text)
        cmd = f'''source {macro.DB_ENV_PATH}; gs_expansion -V'''
        self.log.info(cmd)
        res = self.pri_node.sh(cmd).result()
        self.log.info(res)
        self.assertIn('gs_expansion', res, text + '失败')

        text = '-----gs_expansion --version expect: 显示正常-----'
        self.log.info(text)
        cmd = f'''source {macro.DB_ENV_PATH}; gs_expansion --version'''
        self.log.info(cmd)
        res = self.pri_node.sh(cmd).result()
        self.log.info(res)
        self.assertIn('gs_expansion', res, text + '失败')

    def tearDown(self):
        self.log.info(f'-----{os.path.basename(__file__)} end-----')